extends CharacterBody2D

signal  star_entered

const SPEED = 100.0
const texture_arr = [preload("res://textures/Rocks/starGold.png"), preload("res://textures/Rocks/starSilver.png"),preload("res://textures/Rocks/starBronze.png")]
var index :int = 0

func _ready():
	index = randi_range(0,2)
	$Sprite2D.set_texture(texture_arr[index])

func _physics_process(delta):
	velocity.x -= SPEED * delta
	move_and_slide()
	if position.x <=-$Sprite2D.texture.get_size().x:
		queue_free()
		

func _on_area_2d_body_entered(body):
	if body.is_in_group("plane"):
		star_entered.emit(index)
		queue_free()
